package com.spic.business.violation.supervision.speed.controller;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import com.spic.business.violation.supervision.speed.service.IViolationsSpeedRecordDirtyService;
import com.spic.common.core.web.controller.BaseController;
import com.spic.common.core.web.domain.AjaxResult;
import com.spic.common.core.web.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.spic.business.violation.supervision.speed.domain.ViolationsSpeedRecordDirty;

/**
 * 超速记录Controller
 * 
 * @author ruoyi
 * @date 2022-11-24
 */
@RestController
@RequestMapping("/violation/dirty")
public class ViolationsSpeedRecordDirtyController extends BaseController
{
    @Autowired
    private IViolationsSpeedRecordDirtyService violationsSpeedRecordDirtyService;

    /**
     * 查询超速记录列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ViolationsSpeedRecordDirty violationsSpeedRecordDirty)
    {
        startPage();
        List<ViolationsSpeedRecordDirty> list = violationsSpeedRecordDirtyService.selectViolationsSpeedRecordDirtyList(violationsSpeedRecordDirty);
        return getDataTable(list);
    }

    /**
     * 获取超速记录详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(violationsSpeedRecordDirtyService.selectViolationsSpeedRecordDirtyById(id));
    }

    /**
     * 新增超速记录
     */
    @PostMapping
    public AjaxResult add(@RequestBody ViolationsSpeedRecordDirty violationsSpeedRecordDirty)
    {
        return toAjax(violationsSpeedRecordDirtyService.insertViolationsSpeedRecordDirty(violationsSpeedRecordDirty));
    }

    /**
     * 修改超速记录
     */
    @PutMapping
    public AjaxResult edit(@RequestBody ViolationsSpeedRecordDirty violationsSpeedRecordDirty)
    {
        return toAjax(violationsSpeedRecordDirtyService.updateViolationsSpeedRecordDirty(violationsSpeedRecordDirty));
    }

    /**
     * 删除超速记录
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(violationsSpeedRecordDirtyService.deleteViolationsSpeedRecordDirtyByIds(ids));
    }

    /**
     * 不合规数据统计
     * @return
     */
    @GetMapping("statistics")
    public AjaxResult statistics() {
        Map<String, Integer> map = violationsSpeedRecordDirtyService.statistics();
        return AjaxResult.success(map);
    }
}
